package aip.project.controller.bio.Admin.AggiungiProdOff;

import java.util.ArrayList;
import java.util.List;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.datastore.Datastore;

import aip.project.model.Offerte;
import aip.project.model.Prodotto;
import aip.project.service.OfferteService;
import aip.project.service.ProdottoService;

public class IndexController extends Controller {

    @Override
    public Navigation run() throws Exception {
        ProdottoService prs = new ProdottoService();
        List<String[]> lpr = new ArrayList<String[]>();
        for (Prodotto p: prs.getProdottoList())
            lpr.add(new String[]{p.getNome(), Datastore.keyToString(p.getKey())});
        requestScope("prodotti", lpr);
        OfferteService os = new OfferteService();
        List<String[]> lo = new ArrayList<String[]>();
        for (Offerte o: os.getOffertaList())
            lo.add(new String[]{o.getNome(), Datastore.keyToString(o.getKey())});
        requestScope("offerte", lo);
        return forward("index.jsp");
    }
}
